home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / windows / wdj1096.zip / ZOLMAN.ZIP / WRAPOCX.H < prev    next >
C/C++ Source or Header  |  1996-07-23  |  979b  |  48 lines

  1. //
  2. //wrapocx.h
  3. //
  4. //A template for easy OCX reuse.
  5. //this is for use with projects generated with AppWizard
  6.  
  7. #include "stdafx.h"
  8. template <class OCX>
  9. class COcxWrap
  10. {
  11. private:
  12.     OCX m_Ocx;
  13.     CWnd m_wnd;
  14. public:
  15.     COcxWrap(UINT id);
  16.     ~COcxWrap();
  17.     inline OCX& Ocx();
  18. };
  19.  
  20. template <class OCX>
  21.  
  22. COcxWrap<OCX>::COcxWrap(UINT id) : m_wnd(), m_Ocx()
  23. {
  24.     m_wnd.CreateEx(0,               //extended styles
  25.     AfxRegisterWndClass(0),             //new class
  26.     "ContainerWindow",              //window name
  27.     WS_OVERLAPPED,                  //style
  28.     10,10,200,200,                  //position
  29.      0L,                        //hParent
  30.      0L);                       //hMenu
  31.     
  32.     m_Ocx.Create(AfxRegisterWndClass(0), "OCX", 0, CRect(10,10,20,20), &m_wnd, id);
  33. }
  34.  
  35. template <class OCX>
  36. OCX& COcxWrap<OCX>::Ocx()
  37. {
  38.     return m_Ocx;
  39. }
  40.  
  41. template <class OCX>
  42. COcxWrap<OCX>::~COcxWrap()
  43. {
  44.     m_wnd.DestroyWindow();  
  45. }
  46.  
  47.  
  48.